﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VNext.Tools
{
    public class FielHelper
    {
        public static void CreateDirctory(string filePath, bool isDelete = false)
        {
            string directoryPath;
            if (Path.GetExtension(filePath).Length > 0)
            {
                directoryPath = Path.GetDirectoryName(filePath);
            }
            else
            {
                directoryPath = filePath;
            }

            if (directoryPath == null)
            {
                throw new Exception($"the path should be error, please check : {filePath}");
            }

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
                System.Threading.Thread.Sleep(100);
            }
            else if (isDelete)
            {
                Directory.Delete(directoryPath, true);
            }
        }
    }
}
